<?php
class PhoneBookAction extends CommonAction {
	// TODO - Insert your code here
	
	
	public function _before_index() {
		$model = M ( "PhoneBook" );
		$list = $model->getField ( 'id,fullname,nickname,duty,mobile,phone,email,qq' );
		$this->assign ( 'groupList', $list );
	}
	public function _before_add() {
		$model = M ( "PhoneBook" );
		$list = $model->select ();
		$this->assign ( 'list', $list );
	}
	public function _before_edit() {
		$model = M ( "PhoneBook" );
		$list = $model->select ();
		$this->assign ( 'list', $list );
	}
	
	/**
	 * 添加过滤条件
	 * @param  $map
	 */
	 public function _filter(&$map)
	 {
	$fullname=$_REQUEST['fullname'];
	if(!empty ($fullname))
	{
	$map['fullname'] = array('like',"%".$fullname."%");
	
	}
	$this->assign('fullname',$fullname);
	$userid=$_SESSION[C('USER_AUTH_KEY')];
	$map['userid']=$userid;
	} 

	/**
	 * 共享通讯录
	 */
public function sharedindex()
{
	   // $id=$_REQUEST['id'];
		$phonebook=M('PhoneBook');
		$fullname=$_REQUEST['fullname'];
		/* if(!empty($id))
		{
			$map['id']=$id;
		} */
		if(!empty ($fullname) )
		{
			$map['fullname']=array('like',"%".$fullname."%");
		}
		//查找共享字段的值
		$map['isshared']=1;
		$this->assign("fullname",$fullname);
	    $this->_list($phonebook, $map);
	    $this->display();
} 

}
?>